/**
 * 希尔排序
 */
Array.prototype.shell = function(){

    let leng = this.length;
    let gap = Math.floor(leng * 0.5);

    while(gap > 0){
        for (let i = 0; i< gap ; i++) {
           for(let j = i+gap ; j<leng ; j+=gap){
                 let temp = this[j];
                 let k =j-gap;
                 while(k>=0 && this[k] > temp){
                    this[k+gap] = this[k];
                    k-=gap
                 }
                 this[k+gap] = temp      
           }
        }
        gap = Math.floor(gap * 0.5)
    }

}

let a = [1,2,50,3,60,-5,41];
a.shell();
console.log(a);